<!-- /* Description for file.
 * 项目管理修改
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/projectmanagements
 * @since         ues
 * @version       V0.0.1
 * @modifiedby   张海杰2011年0705
 * @lastmodified  张海杰2011年0705
 */
 -->

<?php
	echo $html->css ( 'jquery-validate/css/screen' );
echo $html->css ( 'style' );
//echo $javascript->link('jquery');
	echo $html->css('flexigrid');
	echo $html->css('start/jquery-ui-1.8.2.custom');
	echo $javascript->link('flexigrid/flexigrid'); 
	//echo $javascript->link ('formValidate');
	//echo $javascript->link('DatePicker/WdatePicker');
	echo $javascript->link('jquery-ui-1.8.2.custom.min');

?>

<script type="text/javascript">
	function mycheck() {
		$("#projectedit").submit();	
	}		
</script>

<script type="text/javascript">

//添加验证
$(document).ready(function() {

	//验证是否必填
	function test(id)
	{
		var srt = "font#" + id;
		var isValidate =  $(srt).text();
		var validate = $.trim(isValidate);
		if(validate == "*"){
			return true;
		} else {
			return false;
		}
	}
	
	$.validator.setDefaults({       
		 submitHandler: function(form) {    
		  form.submit();    
		}       
	});   
			
	$("#ProjectmanagementEditForm").validate({
		rules: {
		"data[Projectmanagement][projectCode]":{
			required: test("projectCode"),string:true,stringMinLength:0,stringMaxLength:50
			},
			"data[Projectmanagement][totalEmployment]":{
				required: test("totalEmployment"),string:true,stringMinLength:0,stringMaxLength:50,digits:true
				},
				"data[Projectmanagement][linkman]":{
					required: test("linkmand"),selectNone:true
					},//客户联系人
					"data[Projectmanagement][salesMan]":{
						required: test("salesMan"),selectNone:true
						},//销售员
						"data[Projectmanagement][projectAssistant]":{
							required: test("projectAssistant"),alowsome:true
							},//项目助理
							
		"data[Projectmanagement][start]":{
			required: false,dateISO:true
			},
		"data[Projectmanagement][end]" :{
			required: false,dateISO:true
			},
		"data[Projectmanagement][advisorDeduct]":{
			required: false,stringMinLength:0,stringMaxLength:50
			},
		"data[Projectmanagement][salesDeduct]":{
			required: false,stringMinLength:0,stringMaxLength:50
			},
		"data[Projectmanagement][projectAmount]":{
			required: false,stringMinLength:0,stringMaxLength:50,number:true
			},
		"data[Projectmanagement][memo]":{
			required: false
			}
		},
		messages:{},
		focusInvalid:false,
		onkeyup:false,
		errorPlacement:function(error, element){error.appendTo(element.parent());}
	});
});
//验证结束


	$(function(){
		$(".datepickerSpan :input").datepicker({
			inline: true
		});
		 $('.datepickerSpan :input').datepicker('option', {dateFormat: "yy-mm-dd"});
		 $('.datepickerSpan :input').datepicker( "option", "closeText", 'X' );
		 $("#projectmanagementsprojectDate").val("<?php echo $data["Projectmanagement"]["projectDate"];?>");
		 $("#projectmanagementsendDate").val("<?php echo $data["Projectmanagement"]["endDate"];?>");
	});
</script>

<script type="text/javascript">
var Assistant=false;
	$(function()
		{
			$("#close").click(function(){		
				window.close();							
			});
			$("#addrec").click(function(){
				window.open('<?php echo ROOT_WEB_PATH; ?>/recruitpositions/save');
			});
			$("#addallowperson").click(function(){		
				getDelStr();
				$(".toolbarStyle").toggle();
			});
			$("#closeallowperson").click(function(){		
				$(".toolbarStyle").toggle();
			});
			$("#addallowperson1").click(function(){		
				getDelStr();
				$(".toolbarStyle1").toggle();
			});
			$("#closeallowperson1").click(function(){		
				$(".toolbarStyle1").toggle();
			});
			
			$("#selass").click(function(){	
				Assistant=true;
				$(".toolbarStyle").toggle();
			});

			$("#advisor").click(function(){	
				Assistant=false;
				$(".toolbarStyle1").toggle();
			});
		});
	function getDelStr() {
		var delArr = Array();
		if(Assistant)
		{
			//delArr = $("input[name='assistant'][checked]");
    		$("input[name='assistant']").each(function(){ 
                  if(this.checked) {
                  	delArr.push($(this).val());
                  }             
            })			
		}
		else
		{
			// delArr =$("input[name='advisor'][checked]");
    		$("input[name='advisor']").each(function(){ 
                  if(this.checked) {
                  	delArr.push($(this).val());
                  }             
            })			
		}
		if(delArr.length==0)
		{
			alert("请选择用户!");
			return;
		}
		var str = "";
		for(var i=0;i<delArr.length;i++) {
			//var del = delArr[i].value;
			del = delArr[i];
			if(i > 0) {
				str += ",";
			}
			str += del;
		}
		if(Assistant)
		{
			$("#projectmanagementsprojectAssistant").val(str);
		}
		else
		{
			$("#projectmanagementsprojectAdvisor").val(str);
		}
	}
</script>

<script type="text/javascript">

  var message="<?php echo $message;?>";
  if(message!="")
  {
	window.opener.tablereload(message);
 	window.close();
  }
</script>
<!-- 当前位置-->
<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('Projectmanagements');//一级目录
										   echo '>';echo __('Projectmanagements');//一级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('Projectmanagements Edit',true));//当前操作地用span加粗?> 						  
		</td>
	</tr>
</table>
</div>
<!-- 当前位置-->

<div class="tabflex">
<div class="toolbarStyle" style="display:none;left:59%;top:33%">
	<?php 
		foreach ($users as $eachrecord)
		{
			echo $form->checkbox($eachrecord['User']['username'], array('value' => $eachrecord['User']['username'],'name'=>'assistant'));
			echo $eachrecord['User']['username'];
		}
	?>

<table width="100%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php echo $form->button('确定',array('class'=>'oksubmit','id'=>'addallowperson'));?>  <!-- __('reset', true)取消-->
		<td width="100"><?php echo $form->button('取消',array('class'=>'cancelbutton','id'=>'closeallowperson'));?>  <!-- __('reset', true)取消-->
	</tr>
</table>
</div>

<div class="toolbarStyle1" style="display:none;left:59%;top:26%">
	<?php 
		foreach ($users as $eachrecord)
		{
			echo $form->checkbox($eachrecord['User']['username'], array('value' => $eachrecord['User']['username'],'name'=>'advisor'));
			echo $eachrecord['User']['username'];
		}
	?>

<table width="100%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php echo $form->button('确定',array('class'=>'btn2','id'=>'addallowperson1'));?>  <!-- __('reset', true)取消-->
		<td width="100"><?php echo $form->button('取消',array('class'=>'btn2','id'=>'closeallowperson1'));?>  <!-- __('reset', true)取消-->
	</tr>
</table>
</div>

<fieldset><legend><?php echo __('Projectmanagements')?></legend>
<?php echo $form->create('Projectmanagement',array('action'=>'edit','type'=> 'post','id'=>'ProjectmanagementEditForm'));?>
<?php echo $form->hidden('table',array('id'=>'table','default'=>$table));?>	
<?php echo $form->hidden('id',array('default'=>$data["Projectmanagement"]["id"]));?>
<table width="100%" cellspacing="0" cellpadding="0" border="0"
	style="text-align: left">
		<tr>
			<td></td>
			<td><?php echo __('projectmanagementsprojectCode',true);//项目编号:?>:
				<font color="red" id="projectCode">
					<?php if($fields['projectCode'] == 1 && $fields['projectCode'] !=null){echo "*";}?>
				</font>				
			</td>
			<td colspan="4">
		<?php 
			echo $form->input('projectCode',array('label'=>false,'class'=>'TextBoxE3','default'=>$data["Projectmanagement"]["projectCode"],'id'=>'projectmanagementsprojectCode'));
		?>
		</td>
		</tr>
		
		<tr>
			<td width="5%"></td>
			<td width="10%"><?php echo __('projectmanagementsproject DateTime',true);//项目日期:?>:</td>
			<td width="30%"><span class="datepickerSpan">
		<?php 
			echo $form->input('start',array('label'=>false,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectDate"],'id'=>'projectmanagementsprojectDate'));
		?></span>
			</td>
			<td width="10%"><?php echo __('EndUseTime',true);//结束日期:?>:</td>
			<td width="30%"><span class="datepickerSpan">
		<?php 
			echo $form->input('end',array('label'=>false,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["endDate"],'id'=>'projectmanagementsendDate'));
		?></span>
		</td>
		<td width="5%"></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagementsproject Company',true);//项目公司:?>:</td>
			<td>
		<?php 
			echo $form->input('projectCompany',array('options'=>$op1,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectCompany"],'class' => 'TextBoxE0','label'=>false,'id'=>'projectmanagementsprojectCompany'));
		?>
			</td>
			<td ><?php echo __('projectmanagementsproject CompanyPosition',true);//项目职位:?>:</td>
			<td>
		<?php 
			echo $form->input('projectCompanyPosition',array('options'=>$op2,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectCompanyPosition"],'class' => 'TextBoxE0','label'=>false,'id'=>'projectmanagementsprojectCompanyPosition'));
		?>
		
		</td>
		<td><?php echo $form->button('添加职位',array('class'=>'btn4','id'=>'addrec'));?></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagementslinkman',true);//客户联系人:?>:
					<font color="red" id="linkmand">
					<?php if($fields['linkman'] == 1 && $fields['linkman'] !=null){echo "*";}?>
				</font>			
			</td> 
			<td>
		<?php 
			echo $form->input('linkman',array('options'=>$op4,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["linkman"],'class' => 'TextBoxE0','label'=>false,'id'=>'projectmanagementslinkman'));
		?>
			</td>
			<td ><?php echo __('projectmanagements projectAdvisor',true);//项目顾问:?>:</td>
			<td>
		<?php 
			echo $form->input('projectAdvisor',array('class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectAdvisor"],'class' => 'TextBoxE0','label'=>false,'id'=>'projectmanagementsprojectAdvisor'));
		?>
		</td>
		<td><?php echo $form->button('选择顾问',array('class'=>'btn4','id'=>'advisor'));?></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagements advisorDeduct',true);//顾问提成:?>:</td>
			<td>
		<?php 
			echo $form->input('advisorDeduct',array('label'=>false,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["advisorDeduct"],'id'=>'projectmanagementsadvisorDeduct'));
		?>
			</td>
			<td ><?php echo __('Projectstates',true);//项目状态:?>:</td>
			<td>
		<?php 
			echo $form->input('projectStatue',array('options'=>$op3,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectStatue"],'label'=>false,'id'=>'projectmanagementsprojectStatue'));
		?>
		</td>
		<td ></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagements projectManage',true);//项目负责人:?>:</td>
			<td>
		<?php 
			echo $form->input('projectManage',array('class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectManage"],'label'=>false,'id'=>'projectmanagementsprojectManage'));
		?>
			</td>
			<td ><?php echo __('projectmanagementsprojectAssistant',true);//项目助理:?>:
					<font color="red" id="projectAssistant">
					<?php if($fields['projectAssistant'] == 1 && $fields['projectAssistant'] !=null){echo "*";}?>
				</font>			
			</td>
			<td>
		<?php 
			echo $form->input('projectAssistant',array('default'=>$data["Projectmanagement"]["projectAssistant"],'class'=>'TextBoxE1','label'=>false,'id'=>'projectmanagementsprojectAssistant'));
		?>
		</td>
		<td><?php echo $form->button('选择助理',array('class'=>'btn4','id'=>'selass'));?></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagementssalesMan',true);//销售员:?>:
				<font color="red" id="salesMan">
					<?php if($fields['salesMan'] == 1 && $fields['salesMan'] !=null){echo "*";}?>
				</font>				
			</td>
			<td>
		<?php 
			echo $form->input('salesMan',array('options'=>$op,'default'=>$data["Projectmanagement"]["salesMan"],'class'=>'TextBoxE1','label'=>false,'id'=>'projectmanagementssalesMan'));
		?>
			</td>
			<td ><?php echo __('projectmanagements salesDeduct',true);//销售提成:?>:</td>
			<td>
		<?php 
			echo $form->input('salesDeduct',array('label'=>false,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["salesDeduct"],'id'=>'projectmanagementssalesDeduct'));
		?>
		</td>
		<td ></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagementsproject Level',true);//项目级别:?>:</td>
			<td>
		<?php 
			$op5=array("★"=>"★","★★"=>"★★","★★★"=>"★★★","★★★★"=>"★★★★","★★★★★"=>"★★★★★");
			echo $form->input('projectLevel',array('options'=>$op5,'default'=>$data["Projectmanagement"]["projectLevel"],'class' => 'TextBoxE4','label'=>false,'id'=>'projectmanagementsprojectLevel'));
		?>
			</td>
			<td ><?php echo __('projectmanagements keyProject',true);//关键项目:?>:</td>
			<td>
		<?php 
			$op6=array("0"=>"否","1"=>"是");
			echo $form->input('keyProject',array('options'=>$op6,'default'=>$data["Projectmanagement"]["keyProject"],'class'=>'TextBoxE1','label'=>false,'id'=>'projectmanagementskeyProject'));
		?>
		</td>
		<td ></td>
		</tr>
		
		<tr>
			<td ></td>
			<td ><?php echo __('projectmanagements projectAmount',true);//项目金额:?>:</td>
			<td>
		<?php 
			echo $form->input('projectAmount',array('label'=>false,'div'=>false,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["projectAmount"],'id'=>'projectmanagementsprojectAmount'));
			echo "元/人次"
		?>
			</td>
			<td ><?php echo __('projectmanagementstotalEmployment',true);//雇佣人数:?>:
				<font color="red" id="totalEmployment">
					<?php if($fields['totalEmployment'] == 1 && $fields['totalEmployment'] !=null){echo "*";}?>
				</font>				
			</td>
			<td>
		<?php 
			echo $form->input('totalEmployment',array('label'=>false,'class'=>'TextBoxE1','default'=>$data["Projectmanagement"]["totalEmployment"],'id'=>'projectmanagementstotalEmployment'));
		?>
		</td>
		<td ></td>
		</tr>
		
		<tr>
			<td ></td>
			<td style="vertical-align:top;"><?php echo __('projectmanagements memo',true);//项目备注:?>:</td>
			<td colspan="4">
		<?php 
			echo $form->textarea('memo',array('label'=>false,'default'=>$data["Projectmanagement"]["memo"],'id'=>'projectmanagementsmemo','class' => 'areaStyle'));
		?>
		</td>
		</tr>
</table>
</fieldset>
</div>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php echo $form->button('确定',array('type'=>'submit','id'=>'editallowperson1','class'=>'oksubmit'));?>  <!-- __('reset', true)取消-->
		<td width="100"><?php echo $form->button('关闭',array('class'=>'btn2','id'=>'close'));?>  <!-- __('reset', true)取消-->
		</td>
	</tr>
</table>
<?php echo $form->end();?>
